﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Quarto
{
    public class Coup
    {
        private Piece piece;
        private int x;
        private int y;
        private int valeur;
        private int indice_piece_selectionnee;

        public Piece Piece
        {
            get { return piece; }
            set { piece = value; }
        }
        public int X
        {
            get { return x; }
            set { x = value; }
        }
        public int Y
        {
            get { return y; }
            set { y = value; }
        }
        public int Valeur
        {
            get { return valeur; }
            set { valeur = value; }
        }
        public int Indice_piece_selectionnee
        {
            get { return indice_piece_selectionnee; }
            set { indice_piece_selectionnee = value; }
        }
        
        public Coup()
        {
        }

        public Coup(Piece piece, int i, int j, int valeur, int indice)
        {
            this.piece = piece;
            this.x = i;
            this.y = j;
            this.valeur = valeur;
            this.indice_piece_selectionnee = indice;
        }

        public bool appliquer_coup(Grille g, Liste_Piece liste_piece)
        {
            if (g.Tab_case[this.x, this.y].Rempli)
                return false;
            else
            {
                g.Tab_case[this.x, this.y].Piece_case = this.piece;
                g.poser_piece_grille(this.x, this.y, this.indice_piece_selectionnee, liste_piece);
                g.Tab_case[this.x, this.y].Rempli = true;
                return true;
            }
        }

        public bool annuler_coup(Grille g, Liste_Piece liste)
        {
            if (g.Tab_case[this.x, this.y].Rempli)
            {
                g.Tab_case[this.x, this.y].Piece_case = null;
                g.Tab_case[this.x, this.y].Rempli = false;
                liste.Liste_piece_posee[this.indice_piece_selectionnee] = false;
                liste.Liste_piece_depart[this.indice_piece_selectionnee].Pose = false;
                return true;
            }
            else
                return false;
        }
    }
}
